//
//  AXHomeXxtydTjCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/26.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXHomeXxtydTjCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@implementation AXHomeXxtydTjCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];

    }
    return self;
}


- (void)creatView {
    
    /** 用户图像 */
    self.userImageView = [[UIImageView alloc]init];
    self.userImageView.cornerRadius = 25;
    self.userImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.userImageView.clipsToBounds=YES;//
    self.userImageView.image = [UIImage imageNamed:@"xy.jpeg"];
    [self.contentView addSubview:self.userImageView];
    /** 店铺名字 */
    self.shopNameLabel = [[UILabel alloc]init];
    self.shopNameLabel.text = @"小猪佩奇店铺";
    self.shopNameLabel.font = FONT_FOURTEEN;;
    [self.contentView addSubview:self.shopNameLabel];
    
    self.starAppraiseView = [[ ZXSampleStarAppraiseView alloc]init];
    self.starAppraiseView.score = 5;
    [self.contentView addSubview:self.starAppraiseView];
    
    /** 距离 */
    self.distanceLabel = [[UILabel alloc]init];
    self.distanceLabel.text = @"北京路同德广场  800m";
    self.distanceLabel.textColor = COLOR_GREEN;
    self.distanceLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.distanceLabel];
    
    
}


- (void)setlayout {
    
    self.userImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .centerYEqualToView(self.contentView)
    .widthIs(50)
    .heightIs(50);
    
    self.starAppraiseView.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 20)
    .widthIs(100)
    .heightIs(30);
    
    self.shopNameLabel.sd_layout
    .leftSpaceToView(self.userImageView, 10)
    .topSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.starAppraiseView, 10)
    .minHeightIs(60)
    .autoHeightRatio(0);
    
   
    
    self.distanceLabel.sd_layout
    .leftSpaceToView(self.userImageView, 10)
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.shopNameLabel, 10)
    .heightIs(20);
    

    
    [self setupAutoHeightWithBottomView:self.distanceLabel bottomMargin:10];
}


- (void)setModel:(AXHomeXxtydTjModel *)model {
    _model = model;
    /** 星星 */
    _starAppraiseView.score = [_model.storeLevel integerValue];
    [self.userImageView sd_setImageWithURL:[NSURL URLWithString:_model.storeLogo] placeholderImage:[UIImage imageNamed:@"placeHold"]];
    _shopNameLabel.text = _model.storeName;
    _distanceLabel.text = _model.distance;

    [self setlayout];
 
    
}

@end

